package thread;

import java.util.Scanner;

public class Demo8 {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            /*Thread c = new Thread;
            while (!c.isInterrupted());*/
            while (!Thread.currentThread().isInterrupted()) {
                System.out.println("hello thread");
                try {
                    Thread.sleep(100_000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        thread.start();
        System.out.println("输入1结束进程");
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        if (n == 1) thread.interrupt();
    }
}
